package cn.geminis.everydata.service.model;

import cn.geminis.data.jpa.DynamicRepository;
import cn.geminis.everydata.service.entity.Category;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

/**
 * @author Allen
 */
public interface CategoryRepository extends DynamicRepository<Category, String> {

    /**
     * 删除节点以及子节点
     *
     * @param pathId 路径编号
     * @return 删除数量
     */
    @Modifying
    @Transactional(rollbackOn = Exception.class)
    @Query("delete from Category o where o.pathId like ?1")
    int deleteByPathId(String pathId);

}
